<html>
  <head>
    <title>窗口标题</title>
  </head>

  <body>
    <div
      style="
        padding: 60px;
        font-size: 38px;
        font-weight: bold;
        text-align: center;
      "
    >
      hello world
    </div>
    <button id="openDevToolBtn">打开开发者工具</button>
    <button id="makeNewWindow">打开新窗口</button>
    <button id="makeNewWindow2">打开新窗口2</button>
    <button id="sendMsg1">发送消息1</button>
    <script>
      let { remote } = require("electron");
      document
        .querySelector("#openDevToolBtn")
        .addEventListener("click", function () {
          remote.getCurrentWindow().webContents.openDevTools();
        });

      let win = null;
      document
        .querySelector("#makeNewWindow")
        .addEventListener("click", function () {
          win = new remote.BrowserWindow({
            webPreferences: { nodeIntegration: true, enableRemoteModule: true },
          });
        });

      let mainModel = remote.require("./mainModel.js");
      let win2 = null;
      document
        .querySelector("#makeNewWindow2")
        .addEventListener("click", () => {
          win2 = mainModel.makeWin();
          win2.loadFile("index.html");
        });

      let { ipcRenderer } = require("electron");
      document.querySelector("#sendMsg1").addEventListener("click", () => {
        ipcRenderer.send(
          "msg_render2main",
          { name: "param1" },
          { name: "param2" }
        );
      });
    </script>
  </body>
</html>

